package com.iplant.wms.service.po.mfs;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.wms.service.basicenum.wms.WMSStoreAreaTypes;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


/**
 * 库区 按功能划分  理货区（入库） 存储区（存储整箱，大批量）   拣货区（散装，可用于配料取货，缺料需要从存储区补货）
 */
@DBBasePO(TableName = "wms_store_area", CheckName = {"Code", "StoreID,StoreRegionID,Name"},
        Schemas = DBSchemas.WMS, CodeAuto = true, CodePrefix = "KQ-",Cache = true)
public class WMSStoreArea extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    @DBCondition(CompareType = DBCondition.DBCompareType.findInSet)
    @DBJoin(name = "FactoryIDList", tableName = "wms_store", tableAsName = "r2", Schemas = DBSchemas.WMS,
            MainTableField = "StoreID")
    public List<Integer> FactoryIDList = new ArrayList<>();


    @DBJoinMulti(Name = "Code", TableName = "fmc_factory", MainTableField = "FactoryIDList", Schemas = DBSchemas.Basic)
    public String FactoryCode = "";

    @DBJoinMulti(Name = "Name", TableName = "fmc_factory", MainTableField = "FactoryIDList", Schemas = DBSchemas.Basic)
    public String FactoryName = "";

    @DBCondition
    @DBField
    public int StoreID = 0;

    @DBCondition
    @DBJoin(name = "Code", tableName = "wms_store", tableAsName = "r2", Schemas = DBSchemas.WMS,
            MainTableField = "StoreID")
    public String StoreCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "wms_store", tableAsName = "r2", Schemas = DBSchemas.WMS,
            MainTableField = "StoreID")
    public String StoreName = "";

    @DBCondition
    @DBField
    public int StoreRegionID = 0;

    @DBCondition
    @DBJoin(name = "Code", tableName = "wms_store_region", tableAsName = "r1", JoinIndex = 2, Schemas = DBSchemas.WMS,
            MainTableField = "StoreRegionID")
    public String StoreRegionCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "wms_store_region", tableAsName = "r1", JoinIndex = 2, Schemas = DBSchemas.WMS,
            MainTableField = "StoreRegionID")
    public String StoreRegionName = "";

    @DBCondition
    @DBField
    public int TypeID = WMSStoreAreaTypes.Stock.getValue();

    /**
     * 库区类型 需要定于库区类型枚举  存储区 分拣区（出库）  理货（入库）  WMSStoreAreaTypes
     */
    public String TypeName = "";

    /**
     * 运输方式
     */
    @DBField
    public String TransportMode = "";

    /**
     * 入库过度库位 库区入库时，必须从指定库位上架 默认不设置 ,即可以直接通过理货区所有库位上架
     */
    @DBField
    public List<Integer> TransferInStationID = new ArrayList<Integer>();

    @DBJoinMulti(Name = "Code", TableName = "wms_store_station", MainTableField = "TransferInStationID", Schemas = DBSchemas.WMS)
    public String TransferInStationName = "";

    @DBJoinMulti(Name = "Code", TableName = "wms_store_station", MainTableField = "TransferInStationID", Schemas = DBSchemas.WMS)
    public String TransferInStationCode = "";

    /**
     * 拣选过度库位  此库区拣货时 默认已此过渡库位为拣货目的库位  默认不设置,即可以直接拣选到所有拣选区库位上
     */
    @DBField
    public List<Integer> TransferOutStationID = new ArrayList<Integer>();

    @DBJoinMulti(Name = "Code", TableName = "wms_store_station", MainTableField = "TransferOutStationID", Schemas = DBSchemas.WMS)
    public String TransferOutStationName = "";

    @DBJoinMulti(Name = "Code", TableName = "wms_store_station", MainTableField = "TransferOutStationID", Schemas = DBSchemas.WMS)
    public String TransferOutStationCode = "";

    /**
     * 整箱补货来源  用于给拣货区整箱补货  存储区不允许
     */
    @DBCondition
    @DBField
    public int PackSourceCPFR = 0;

    /**
     * 拆零补货来源  用于给拣货区拆零补货
     * 存储区不允许拆零补货时，允许整箱补货 即不允许存储零散物料
     * 都不允许时 则不能拣货 如废品，退货物料  可以后续通过流程处理这部分物料
     */
    @DBCondition
    @DBField
    public int PieceSourceCPFR = 0;

    @JsonProperty("FactoryIDList")
    public List<Integer> getFactoryIDList() {
        return FactoryIDList;
    }

    public void setFactoryIDList(List<Integer> factoryIDList) {
        FactoryIDList = factoryIDList;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("StoreID")
    public int getStoreID() {
        return StoreID;
    }

    public void setStoreID(int storeID) {
        StoreID = storeID;
    }

    @JsonProperty("StoreCode")
    public String getStoreCode() {
        return StoreCode;
    }

    public void setStoreCode(String storeCode) {
        StoreCode = storeCode;
    }

    @JsonProperty("StoreName")
    public String getStoreName() {
        return StoreName;
    }

    public void setStoreName(String storeName) {
        StoreName = storeName;
    }

    @JsonProperty("StoreRegionID")
    public int getStoreRegionID() {
        return StoreRegionID;
    }

    public void setStoreRegionID(int storeRegionID) {
        StoreRegionID = storeRegionID;
    }

    @JsonProperty("StoreRegionCode")
    public String getStoreRegionCode() {
        return StoreRegionCode;
    }

    public void setStoreRegionCode(String storeRegionCode) {
        StoreRegionCode = storeRegionCode;
    }

    @JsonProperty("StoreRegionName")
    public String getStoreRegionName() {
        return StoreRegionName;
    }

    public void setStoreRegionName(String storeRegionName) {
        StoreRegionName = storeRegionName;
    }

    @JsonProperty("TypeID")
    public int getTypeID() {
        return TypeID;
    }

    public void setTypeID(int typeID) {
        TypeID = typeID;
    }

    @JsonProperty("TypeName")
    public String getTypeName() {

        TypeName = WMSStoreAreaTypes.getEnumType(TypeID).getLabel();
        return TypeName;
    }

    public void setTypeName(String typeName) {
        TypeName = typeName;
    }

    @JsonProperty("TransportMode")
    public String getTransportMode() {
        return TransportMode;
    }

    public void setTransportMode(String transportMode) {
        TransportMode = transportMode;
    }

    @JsonProperty("TransferInStationID")
    public List<Integer> getTransferInStationID() {
        return TransferInStationID;
    }

    public void setTransferInStationID(List<Integer> transferInStationID) {
        TransferInStationID = transferInStationID;
    }

    @JsonProperty("TransferInStationName")
    public String getTransferInStationName() {
        return TransferInStationName;
    }

    public void setTransferInStationName(String transferInStationName) {
        TransferInStationName = transferInStationName;
    }

    @JsonProperty("TransferInStationCode")
    public String getTransferInStationCode() {
        return TransferInStationCode;
    }

    public void setTransferInStationCode(String transferInStationCode) {
        TransferInStationCode = transferInStationCode;
    }

    @JsonProperty("TransferOutStationID")
    public List<Integer> getTransferOutStationID() {
        return TransferOutStationID;
    }

    public void setTransferOutStationID(List<Integer> transferOutStationID) {
        TransferOutStationID = transferOutStationID;
    }

    @JsonProperty("TransferOutStationName")
    public String getTransferOutStationName() {
        return TransferOutStationName;
    }

    public void setTransferOutStationName(String transferOutStationName) {
        TransferOutStationName = transferOutStationName;
    }

    @JsonProperty("TransferOutStationCode")
    public String getTransferOutStationCode() {
        return TransferOutStationCode;
    }

    public void setTransferOutStationCode(String transferOutStationCode) {
        TransferOutStationCode = transferOutStationCode;
    }

    @JsonProperty("PackSourceCPFR")
    public int getPackSourceCPFR() {
        return PackSourceCPFR;
    }

    public void setPackSourceCPFR(int packSourceCPFR) {
        PackSourceCPFR = packSourceCPFR;
    }

    @JsonProperty("PieceSourceCPFR")
    public int getPieceSourceCPFR() {
        return PieceSourceCPFR;
    }

    public void setPieceSourceCPFR(int pieceSourceCPFR) {
        PieceSourceCPFR = pieceSourceCPFR;
    }
}
